package cn.iocoder.yudao.module.cfs.service.datanbusermonitorinfo;

import cn.iocoder.yudao.module.cfs.controller.admin.datanbusermonitorinfo.vo.DataNbUsermonitorinfoPageReqVO;
import cn.iocoder.yudao.module.cfs.controller.admin.datanbusermonitorinfo.vo.DataNbUsermonitorinfoSaveReqVO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.module.cfs.dal.dataobject.datanbusermonitorinfo.DataNbUsermonitorinfoDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import cn.iocoder.yudao.module.cfs.dal.mysql.datanbusermonitorinfo.DataNbUsermonitorinfoMapper;


/**
 * 联网设备NB类型 Service 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
public class DataNbUsermonitorinfoServiceImpl implements DataNbUsermonitorinfoService {

    @Resource
    private DataNbUsermonitorinfoMapper dataNbUsermonitorinfoMapper;

    @Override
    public Long createDataNbUsermonitorinfo(DataNbUsermonitorinfoSaveReqVO createReqVO) {
        // 插入
        DataNbUsermonitorinfoDO dataNbUsermonitorinfo = BeanUtils.toBean(createReqVO, DataNbUsermonitorinfoDO.class);
        dataNbUsermonitorinfoMapper.insert(dataNbUsermonitorinfo);
        // 返回
        return dataNbUsermonitorinfo.getId();
    }

    @Override
    public void updateDataNbUsermonitorinfo(DataNbUsermonitorinfoSaveReqVO updateReqVO) {
        // 校验存在
        validateDataNbUsermonitorinfoExists(updateReqVO.getId());
        // 更新
        DataNbUsermonitorinfoDO updateObj = BeanUtils.toBean(updateReqVO, DataNbUsermonitorinfoDO.class);
        dataNbUsermonitorinfoMapper.updateById(updateObj);
    }

    @Override
    public void deleteDataNbUsermonitorinfo(Long id) {
        // 校验存在
        validateDataNbUsermonitorinfoExists(id);
        // 删除
        dataNbUsermonitorinfoMapper.deleteById(id);
    }

    private void validateDataNbUsermonitorinfoExists(Long id) {
        if (dataNbUsermonitorinfoMapper.selectById(id) == null) {
        }
    }

    @Override
    public DataNbUsermonitorinfoDO getDataNbUsermonitorinfo(Long id) {
        return dataNbUsermonitorinfoMapper.selectById(id);
    }

    @Override
    public PageResult<DataNbUsermonitorinfoDO> getDataNbUsermonitorinfoPage(DataNbUsermonitorinfoPageReqVO pageReqVO) {
        return dataNbUsermonitorinfoMapper.selectPage(pageReqVO);
    }

}